﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>微街秀 >广告图片</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <link href="css/base.css" rel="stylesheet" type="text/css" />
    <link href="plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="plugins/bootstrap-fileinput-master/css/fileinput.min.css" rel="stylesheet"
        type="text/css" />
    <link rel="stylesheet" type="text/css" href="css/css.css" />
    <link href="css/EditAdvertisting.css" rel="stylesheet" type="text/css" />
    <style>
        #upimgs
        {
            width: 300px;
            height: 300px;
        }
        .btn-file
        {
            text-align: center;
            margin-bottom: 50px;
        }
    </style>
</head>
<body>
    <form id="myform">
    <div class="wamtop">
        <div class="topleft" onclick="window.location.href='set.html'">
            <img src="img/14.png" />
        </div>
        <div class="topcententxt">
            文章封面图片</div>
        <div class="topright" style="color: white;">
            确认
        </div>
    </div>
    <div class="Centen">
        <div>
            <div class="pt10">
                <input name="ad_file" id="ad_file" type="file" multiple="true">
            </div>
        </div>
        <input type="hidden" id="hftypeid" value="1" />
        <div style="width: 200px; margin-left: auto; margin-right: auto;">
            <input type="checkbox" id="chkdefault" value="1" onclick="ChangeLogo()" />
            <label for="chkdefault">
                使用默认封面图片</label></div>
    </div>
    <br />
    <br />
    <div style="padding:0 10px 0 10px">
        注： 设置文章封面图片后，将文章分享到微信、QQ等平台，会显示您当前设置的图片，没上传则默认显示微街秀LOGO。</div>

    <script src="js/jquery-2.1.4.min.js" type="text/javascript"></script>
    <script src="js/jquery-form.js" type="text/javascript"></script>
    <script src="plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="plugins/bootstrap-fileinput-master/js/fileinput.min.js" type="text/javascript"></script>
    <script src="plugins/bootstrap-fileinput-master/js/fileinput_locale_zh.js" type="text/javascript"></script>
    <script src="js/jquery-submit.js" type="text/javascript"></script>
    <script src="js/dialog.js" type="text/javascript"></script>
    <script src="js/ajax-upload.js" type="text/javascript"></script>
    <script src="js/ajax-data.js" type="text/javascript"></script>
    <script src="js/base.js" type="text/javascript"></script>
    <script type="text/javascript">
        var logo = "";
        $(function () {
            //文章logo
            $("#ad_file").fileinput({
                showUpload: false,
                showCaption: false,
                showPreview: false,
                browseLabel: '',
                browseClass: "",
                browseIcon: '<img id="upimgs" src="/client/img/cover.jpg" />',
                removeClass: 'hide',
                fileType: "any",
                allowedFileExtensions: ['jpg', 'png', 'gif', 'bmp', 'jpeg']
            });

            //选择了图片提交图片
            $("#ad_file").change(function () {
                if ($(this).val().length == 0) {
                    toast.show("文件格式错误");
                    return;
                }
                wait.show();
                var urlimg = "";
                if ($("#ad_file").val().toLocaleUpperCase().indexOf(".GIF") > -1) {
                    urlimg = "/Client/Ajax/Upload.ashx?Img";
                }
                else {
                    urlimg = "/Client/Ajax/Upload.ashx?Img&is_cut=1&width=300&height=300";
                }
                //上传图片
                $("#myform").ajaxSubmit({
                    type: 'post',
                    dataType: "json",
                    url: urlimg,
                    success: function (data) {
                        wait.dismiss();
                        $("#ad_file").val("");
                        $("#upimgs").attr("src", data.item);
                        logo = data.item;
                    },
                    error: function (XmlHttpRequest, textStatus, errorThrown) {
                        wait.dismiss();
                        $("#ad_file").val("");
                    }
                });
            });

            //获取文章图片
            ajax.GetArticleLogo("login=true", function (data) {
                if (data.code == 0) {
                    if (data.item.articlelogo != "") {
                        logo = data.item.articlelogo;
                        $("#upimgs").attr("src", logo);
                    }
                }
                else
                    Alert(data.msg);
            });

            //提交表单
            $(".topright").bind("click", function () {
                if ($("#upimgs").attr("src") == "") {
                    toast.show("请输入广告图片");
                    return;
                }
                var chk = document.getElementById("chkdefault");
                if (chk.checked)
                    logo = "/client/img/cover.jpg";
                ajax.UpdateInfo("articlelogo=" + logo, function (data) {
                    if (data.code == "成功")
                        Alert("保存成功");
                    else
                        Alert(data.msg);
                });
            });
        });

        function ChangeLogo() {
            var chk = document.getElementById("chkdefault");
            if (chk.checked)
                $("#upimgs").attr("src", "/client/img/cover.jpg");
            else if (logo != '')
                $("#upimgs").attr("src", logo);
        }
    </script>
    </form>
</body>
</html>
